﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Palsta.Core.exp;

namespace Palsta.Core.manifest
{
    class CustomValidation
    {
        #region Members

        private String match;
        private String expressionContext;
        private String expressionText;
        private CustomValidationErrorMsg errorMsg;

        #endregion

        #region Constructors

        public CustomValidation():this("", "", "")
        {
            
        }

        public CustomValidation(String match, String context, String exp)
        {
            this.match = match;
            this.expressionContext = context;
            this.expressionText = exp;
        }

        #endregion

        #region Accessors

        public virtual String Match
        {
            get
            {
                return this.match;
            }
            set
            {
                this.match = value;
            }
        }

        public virtual String ExpressionText
        {
            get
            {
                return this.expressionText;
            }
            set
            {
                this.expressionText = value;
            }
        }

        public virtual String ExpressionContext
        {
            get
            {
                return this.expressionContext;
            }
            set
            {
                this.expressionContext = value;
            }
        }

        public virtual CustomValidationErrorMsg ErrorMsg
        {
            get
            {
                return this.errorMsg;
            }
            set
            {
                this.errorMsg = value;
            }
        }
        #endregion

        #region Override Operators

        public static Boolean operator ==(CustomValidation cv, String tar)
        {
            return cv.Equals(tar);
        }

        public static Boolean operator !=(CustomValidation cv, String tar)
        {
            return !cv.Equals(tar);
        }

        public override bool Equals(object o)
        {
            if (o is String)
            {
                return (this.Match + "/" + this.ExpressionContext).Equals((String)o);
            }
            return false;
        }

        public override int GetHashCode()
        {
            return 0;
        }

        #endregion
    }
}
